using System;
using System.Threading;

namespace Bull.Core
{
    public sealed class IdGenerator {
        private static readonly Lazy<IdGenerator> _instance = new Lazy<IdGenerator>(() => new IdGenerator());

        private int _id;

        private IdGenerator() {
        }

        public static IdGenerator Instance {
            get { return _instance.Value; }
        }

        public int GetId() {
            return Interlocked.Increment(ref _id);
        }
    }
}